import { ActivatedRoute } from '@angular/router';
import { Component, OnInit } from '@angular/core'
import { Location } from '@angular/common'
import { QuestionService } from './service/question.service';

@Component({
    selector: 'app-estate-question',
    templateUrl: './estate-question.component.html',
    styleUrls: ['./estate-question.component.scss']
})
export class EstateQuestionComponent implements OnInit {
    public projectName:any;
    public loading:boolean = true;
    question = [];
    constructor(
        private location: Location,
        private routeInfo: ActivatedRoute,
        private service: QuestionService,

    ) { }

    ngOnInit() {

        let id = this.routeInfo.snapshot.queryParams['project'];
        this.projectName = this.routeInfo.snapshot.queryParams['name'];
      
        this.queryArtcleSummary(id);
    }

    onClickLeft() {
        this.location.back()
    }
    //api
    queryArtcleSummary(id) {
        let req = {
            "pager": {
                "Start": 0,
                "Limit": 10
            },
            "filter": {
                "Lambda": "item=>item.Review&&item.Project=="+id,
                "Navigations": [],
                "Latitude": 28.692499,
                "Longitude": 115.815292
            },
            "sorters": [
                {
                    "Property": "item=>item.Top",
                    "Direction": "Descending"
                },
                {
                    "Property": "item=>item.SubmitTime",
                    "Direction": "Descending"
                }
            ]
        }
        this.service.queryArtcleSummary(req, res => {
            this.question = res.Result.Value;
            this.loading = false;
        });
    };
}
